home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / dbimprtx / _setup.1 / Odbclogn.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-10-08  |  5.3 KB  |  170 lines

  1. VERSION 5.00
  2. Begin VB.Form frmODBCLogon 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "ODBC Logon"
  5.    ClientHeight    =   2325
  6.    ClientLeft      =   2625
  7.    ClientTop       =   2865
  8.    ClientWidth     =   4470
  9.    ControlBox      =   0   'False
  10.    BeginProperty Font 
  11.       Name            =   "Tahoma"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   400
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    HelpContextID   =   2016138
  20.    LinkTopic       =   "Form1"
  21.    LockControls    =   -1  'True
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   2325
  25.    ScaleWidth      =   4470
  26.    ShowInTaskbar   =   0   'False
  27.    Begin VB.CommandButton cmdCancel 
  28.       Cancel          =   -1  'True
  29.       Caption         =   "Cancel"
  30.       Height          =   360
  31.       Left            =   2340
  32.       MaskColor       =   &H00000000&
  33.       TabIndex        =   9
  34.       Top             =   1875
  35.       Width           =   1260
  36.    End
  37.    Begin VB.CommandButton cmdOK 
  38.       Caption         =   "&OK"
  39.       Default         =   -1  'True
  40.       Height          =   360
  41.       Left            =   870
  42.       MaskColor       =   &H00000000&
  43.       TabIndex        =   8
  44.       Top             =   1875
  45.       Width           =   1260
  46.    End
  47.    Begin VB.Frame fraConnection 
  48.       Caption         =   "Connection Values"
  49.       Height          =   1665
  50.       Left            =   120
  51.       TabIndex        =   10
  52.       Top             =   120
  53.       Width           =   4230
  54.       Begin VB.TextBox txtUID 
  55.          Height          =   300
  56.          Left            =   1125
  57.          TabIndex        =   3
  58.          Top             =   600
  59.          Width           =   3015
  60.       End
  61.       Begin VB.TextBox txtPWD 
  62.          Height          =   300
  63.          IMEMode         =   3  'DISABLE
  64.          Left            =   1125
  65.          PasswordChar    =   "*"
  66.          TabIndex        =   5
  67.          Top             =   930
  68.          Width           =   3015
  69.       End
  70.       Begin VB.TextBox txtDatabase 
  71.          Height          =   300
  72.          Left            =   1125
  73.          TabIndex        =   7
  74.          Top             =   1260
  75.          Width           =   3015
  76.       End
  77.       Begin VB.ComboBox cboDSNList 
  78.          Height          =   315
  79.          Left            =   1125
  80.          Sorted          =   -1  'True
  81.          TabIndex        =   1
  82.          Top             =   240
  83.          Width           =   3000
  84.       End
  85.       Begin VB.Label lblLabels 
  86.          AutoSize        =   -1  'True
  87.          Caption         =   "&DSN:"
  88.          Height          =   195
  89.          Index           =   0
  90.          Left            =   135
  91.          TabIndex        =   0
  92.          Top             =   285
  93.          Width           =   360
  94.       End
  95.       Begin VB.Label lblLabels 
  96.          AutoSize        =   -1  'True
  97.          Caption         =   "&UID:"
  98.          Height          =   195
  99.          Index           =   1
  100.          Left            =   135
  101.          TabIndex        =   2
  102.          Top             =   630
  103.          Width           =   330
  104.       End
  105.       Begin VB.Label lblLabels 
  106.          AutoSize        =   -1  'True
  107.          Caption         =   "&Password:"
  108.          Height          =   195
  109.          Index           =   2
  110.          Left            =   135
  111.          TabIndex        =   4
  112.          Top             =   975
  113.          Width           =   750
  114.       End
  115.       Begin VB.Label lblLabels 
  116.          AutoSize        =   -1  'True
  117.          Caption         =   "Data&base:"
  118.          Height          =   195
  119.          Index           =   3
  120.          Left            =   135
  121.          TabIndex        =   6
  122.          Top             =   1320
  123.          Width           =   750
  124.       End
  125.    End
  126. Attribute VB_Name = "frmODBCLogon"
  127. Attribute VB_GlobalNameSpace = False
  128. Attribute VB_Creatable = False
  129. Attribute VB_PredeclaredId = True
  130. Attribute VB_Exposed = False
  131. Option Explicit
  132. Public bOk As Boolean
  133. Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer
  134. Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
  135. Const SQL_SUCCESS As Long = 0
  136. Const SQL_FETCH_NEXT As Long = 1
  137. Private Sub cmdCancel_Click()
  138.   bOk = False
  139.   Me.Hide
  140. End Sub
  141. Private Sub cmdOK_Click()
  142.   bOk = True
  143.   Me.Hide
  144. End Sub
  145. Private Sub Form_Load()
  146.   GetDSNsAndDrivers
  147. End Sub
  148. Sub GetDSNsAndDrivers()
  149.   On Error Resume Next
  150.   Dim i As Integer
  151.   Dim sDSNItem As String * 1024
  152.   Dim sDRVItem As String * 1024
  153.   Dim sDSN As String
  154.   Dim sDRV As String
  155.   Dim iDSNLen As Integer
  156.   Dim iDRVLen As Integer
  157.   Dim lHenv As Long     'handle to the environment
  158.   'get the DSNs
  159.   If SQLAllocEnv(lHenv) <> -1 Then
  160.     Do Until i <> SQL_SUCCESS
  161.       sDSNItem = String(1024, " ")
  162.       sDRVItem = String(1024, " ")
  163.       i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen)
  164.       sDSN = VBA.Left(sDSNItem, iDSNLen)
  165.       If sDSN <> String(iDSNLen, " ") Then cboDSNList.AddItem sDSN
  166.     Loop
  167.   End If
  168.   cboDSNList.ListIndex = 0
  169. End Sub
  170.